package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.enums.ItemType;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.LabelInfo;
import com.atguigu.lease.web.admin.service.LabelInfoService;
import com.atguigu.lease.web.admin.mapper.LabelInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liubo
 * @description 针对表【label_info(标签信息表)】的数据库操作Service实现
 * @createDate 2023-07-24 15:48:00
 */
@Service
public class LabelInfoServiceImpl extends ServiceImpl<LabelInfoMapper, LabelInfo>
        implements LabelInfoService {

    @Autowired
    private LabelInfoMapper labelInfoMapper;

    /**
     * 根据类型查询所有标签列表
     *
     * @param type
     * @return
     */
    @Override
    public List<LabelInfo> labelList(ItemType type) {
        //根据传入的类型确定查询的标签
        LambdaQueryWrapper<LabelInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(type != null, LabelInfo::getType, type);
//        queryWrapper.eq(LabelInfo::getType, type);

        List<LabelInfo> list = labelInfoMapper.selectList(queryWrapper);
        return list;

    }
}




